package cn.jobstart.service.impl;

import cn.jobstart.vo.ResumeProjectExperienceMiniDomainVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import cn.jobstart.modelExt.ResumeProjectExperienceExt;
import cn.jobstart.dao.IResumeProjectExperienceDao;
import cn.jobstart.searchExt.ResumeProjectExperienceSearchExt;
import cn.jobstart.pubInter.IBaseDao;
import cn.jobstart.pubInter.AbstractBaseService;
import cn.jobstart.service.IResumeProjectExperienceService;
import lombok.extern.slf4j.Slf4j;
import cn.jobstart.common.StringUtil;
import cn.jobstart.common.SkList;
import cn.jobstart.pubInter.exception.SkException;

import java.util.List;


/**
 * @author sunke
 * @Date 2023-09-06 15:00:21
 * @description ResumeProjectExperienceService      项目经历
 */
@Service(value = "resumeProjectExperienceService")
@Slf4j
public class ResumeProjectExperienceServiceImpl extends AbstractBaseService<ResumeProjectExperienceExt, ResumeProjectExperienceSearchExt, String> implements IResumeProjectExperienceService {

    @Resource(name = "resumeProjectExperienceDao")
    private IResumeProjectExperienceDao resumeProjectExperienceDao;

    @Override
    public IBaseDao<ResumeProjectExperienceExt, ResumeProjectExperienceSearchExt, String> getDao() {
        return resumeProjectExperienceDao;
    }

    /**
     * 项目经历
     *
     * @param resumeId
     * @return
     */
    @Override
    public String getProjectExperienceStrByResumeId(String resumeId) {

        try {
            List<ResumeProjectExperienceExt> list = getListByResumeId(resumeId);
            return StringUtil.getJsonArrayStrByList(list, ResumeProjectExperienceMiniDomainVO.class);
        } catch (Exception e) {

        }
        return "";

    }

    /**
     * 根据简历ID
     *
     * @param resumeId
     * @return
     */
    @Override
    public List<ResumeProjectExperienceExt> getListByResumeId(String resumeId) {
        if (StringUtil.isNullOrEmpty(resumeId)) {
            return null;
        }
        try {
            return getAllList(ResumeProjectExperienceSearchExt.getInstance().setResumesIdEq(resumeId));
        } catch (SkException e) {

            return null;
        }
    }
}